package com.ruoyi.service.entity.rule;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.service.domain.ServiceRule;

import java.util.Date;

/**
 * 接单退单规则对象 service_rule
 * 
 * @author ZDL
 * @date 2025-03-10
 */

@lombok.Data
public class RuleVO
{
    /** 接退单表主键ID */
    private Long ruleId;

    /** 0 接单规则 1 退单规则 */
    @Excel(name = "规则类型：0 接单规则 1 退单规则")
    private String ruleType;

    /** 提前预约时间 */
    @Excel(name = "需提前预约小时数")
    private Integer ruleHour;

    /** 订单状态 */
    @Excel(name = "所处订单状态")
    private Long ruleFlagId;
    private String ruleFlag;

    /** 退费比率 */
    @Excel(name = "退费比率")
    private Double ruleRefund;

    /** 0 启用 2禁用 */
    @Excel(name = "0 启用 2禁用")
    private String ruleUseFlag;

    /** 0 正常 2 删除 */
    @Excel(name = "0 正常 2 删除")
    private String ruleDelFlag;

    /** 创建者 */
    @Excel(name = "创建者")
    private String ruleCreateBy;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date ruleCreateTime;

    /** 更新者 */
    @Excel(name = "更新者")
    private String ruleUpdateBy;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date ruleUpdateTime;

    /** 备注 */
    @Excel(name = "备注")
    private String ruleRemark;

    public void init(ServiceRule rule) {
        this.ruleId = rule.getRuleId();
        this.ruleType = rule.getRuleType();
        if ("0".equals(this.ruleType)){
            this.ruleHour = rule.getRuleHour();
        }
        if ("1".equals(this.ruleType)){
            this.ruleRefund = rule.getRuleRefund();
        }
        if (rule.getRuleFlag() != null){
            this.ruleFlagId = Long.valueOf(rule.getRuleFlag());
        }
        this.ruleUseFlag = rule.getRuleUseFlag();
        this.ruleDelFlag = rule.getRuleDelFlag();
        this.ruleCreateBy = rule.getRuleCreateBy();
        this.ruleCreateTime = rule.getRuleCreateTime();
        this.ruleUpdateBy = rule.getRuleUpdateBy();
        this.ruleUpdateTime = rule.getRuleUpdateTime();
        this.ruleRemark = rule.getRuleRemark();
    }
}
